package cn.kgc.mushroomdatabaseprovider.service.serviceimpl;

import cn.kgc.mushroomcommon.pojo.Order;
import cn.kgc.mushroomdatabaseprovider.mapper.OrderMapper;
import cn.kgc.mushroomdatabaseprovider.service.OrderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional(readOnly = true)
public class OrderServiceImpl implements OrderService {

    @Resource
    OrderMapper orderMapper;

    @Override
    public List<Order> selectOrderAndShopAndShopcomm(String ordenum) {
         List<Order> orders = orderMapper.selectOrderAndShopAndShopcomm(ordenum);
        return orders;
    }

    @Override
    @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
    public int deleteOrder(Integer id) {
         int i = orderMapper.deleteOrder(id);
        return i;
    }

    @Override
    @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
    public int insertOrder(Order order) {
        System.out.println(order);
        return orderMapper.insertSelective(order);
    }
}
